<?php
/**
 * Created by PhpStorm.
 * User: HouJie
 * Date: 2018-4-3
 * Time: 15:36
 */

namespace Bqdove;

use Bqdove\Container\Container;

/**
 *
 * @method static mixed get($key, $default = null)
 * @method static bool set($key, $value, $ttl = null)
 * @method static bool delete($key)
 * @method static bool clear()
 * @method static mixed forever($key, $value)
 * @method static mixed pull($key)
 * @method static mixed|bool|int increment($key, $value = 1)
 * @method static mixed|bool|int decrement($key, $value = 1)
 * @method static bool has($key)
 * Class Cache
 * @package Bqdove
 */
class Cache extends CacheManager
{

    /**
     * 默认的服务提供者
     * @var null
     */
    protected static $provider = null;

    /**
     * 注册服务容器
     * @param $config
     */
    public static function register($config)
    {
        if (isset($config['default'])) {
            self::$default_store = $config['default'];
        }

        if (self::$provider == null) {
            self::$provider = Container::getContainer(self::$default_store);
        }
        $provider = self::$provider;

        Container::bind(self::$default_store, function () use ($config, $provider) {
            return new $provider($config);
        });
    }


}
